Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(rpc): Add a generate rpc method #8849

Merged
merged 4 commits into from
Sep 9, 2024
Merged

feat(rpc): Add a generate rpc method #8849

merged 4 commits into from
Sep 9, 2024

Conversation

oxarbitrage
Copy link
Contributor

Motivation

Zcashd RPC tests use a method that can generate blocks immediately in the Regtest mode.

Close #8834

Solution

Implement method.

Tests

Manual:

alfredo@spaceship:~/zebra/issue8836/zebra$ curl --silent --data-binary '{"jsonrpc": "1.0", "id":"curltest", "method": "generate", "params": [50] }' -H 'Content-type: application/json' http://127.0.0.1:8232/ | jq
{
  "result": [
    "8bc81d12d00d0bc1cd50730bbf6287eb8e5295676b97bb2c87ab0bf938b78452",
    "3e12c2573d47139e946551bac9f9d00d618207c15df5b6354df081a55e2e1f38",
    "b34ec9434f4bc73e114412046348d5197e7f3b96c95d355ca538abe4f06770f8",
    "36758f0465c498874e1674fcbdb2dd0c964ef6302045ed39107c2eae60c11778",
    "c9f8332a34f8ce4abfa07161ef4b3b71fad2d8dcffcbb0fdd4b83d4c3c800981",
    "adf05c2a72d0fdd0e09be06b30a9da105566e504676d72ca6e7f91d19752bc6a",
    "eaef3b7d5bb3bfa973e3f191ecb1e3f3eadba8748f03562171b3932282e5558c",
    "699af45062d915fbbfe0b59553501eafab82a9d13442f2d16676815e261b257d",
    "21c4a0740cb2050d4a3556470cbfbc352722c62b50307a686ddc2a37517d6f12",
    "4e7ba9f9f7d0aab8c8ad2f70fe799ed04442830bb3ff20d7ab87ada7172cd511",
    "18f7940182a3ca3ac2d9a4d9fd73b895736b00e4b0593f3d855126ec0b8b3c56",
    "eac1b8e7856397f08847dba937d2778f25d398416589aadab36be82b8c357fba",
    "adc6dd3f00457b62735c7f8fbf5c9acc6bf497cc2754d30d4073fbfa07fb5248",
    "a5324ff558ad9884f4b7154e2a1d416dc6ce75de5be4af6f0d0640f808b12a70",
    "b37af61ec204c4a639ae733719c25ada478afa3e7761576c1b74b6ee33a10ba9",
    "3f0e287ef304c223a9ef35afaddd746ef2e20dc96428cfe117e53f74db197d53",
    "0511530a5e597a87a42810815491a152b5d8cdf9661a73bd55301ad439b3c539",
    "38765446837afbd0543fd365c60cd0205c82a265b61249358fbb8dc8fe3b2a1d",
    "3c60203e5f916a98afde162eea8301fb11cdcc81804584737c33f61039b49532",
    "530e88a017c53d4cabbf3125f768516004b3160c2940c419e02ececf245ec753",
    "1e9623831c16bedc78a895f8de298ef02fab2e088d0fe55d196b113e213fdeab",
    "e698024a453ef4dd2efd6fbe3caae3a8502f90c2f2b26c6134c1625457e1d328",
    "be9294e78e5fb1dac41ee22c46b3d6c278e2e8889710897981559656e824e24f",
    "c87d9a0986fb08a5bb7952c6ca92e36c399c4fd9a05ab6fc5d10367c3f9fc817",
    "36bb3fbe17a81078c4f58a74350b66742cc31dc47b656d0c2401df8184f69fa6",
    "799152b276f0b8d0a62517eda0b81e8d2ec7daad30990ae50ecad361be1af2ed",
    "c1ec7aa6cf015a806eb74c1bd746b5e53b38963bb4fb17d6eb3f6b14254bd2cd",
    "6552e88a459b926158a32fef4c22a094a5096c7f098a7afc356bee8d03176c27",
    "e3962633e53996217fe93a756d952d996198adb33aed9f8a79a058aead435376",
    "e55bdc8a6b176d1cc6a334a7d534bb8760cf35136b680cec4fa924f3efbf4c7e",
    "3aa573c3522f208cff880c9204ef597bdd3e639d1cf7976b5a185c5041936e07",
    "f831726cf1ecdc20e7c1cb85c9e9ce1da3bea65371385c863c4e41591509f4a1",
    "a9a5a84880263c951815b6d952db7e13a26798ea313ba7663e37d3317419aa00",
    "e118b808b48226e4155a8467051f02ebd6f73dd9c46b2708a65b2bb8d6c72bb3",
    "a5ed38218b4229201fb8f404e7c557b45b265f746c03e4c6e2303c9006329bc7",
    "c249ffbef431672791659066b02cdd4bb8a9afee132ba138ef4913b0cd488a7b",
    "db89db5cf8664f3d8186cd5dcb428801859fa17b782bb8c88ff1c302fdf652f8",
    "a9fdd2d2c05b0fc894d6d9612bad9bae9dffb334055a909d7043bd39f76ae3cf",
    "8db2bd8a8a104230f9729557905c01dc67b005336df6d95f322a5186456e84b0",
    "7cc306691cbe455ebc3174e7e64f558a801f039431b181efff8ba577fff77157",
    "fa280bd5f4deec102c3cd5b0fe46c825fd42b966b0f052fd3714c343c7508f94",
    "1ed6ca4da5e4c3a43fc0b4b49aad33c505946178091c86114544b0e7da0cea94",
    "e5d73b3b80fa2460b3fb26064a719a0f92a119ed1cde040848a8ae51526c0403",
    "9f9894517eb73ccfd1d61b5c596e974e3a386e7b28100b9616b5318613e2808c",
    "aa1cab5168c737e24a49a494337e97df7be8988b988db61cf24bf198b9ced6d4",
    "8cd58b6387576703906ab701223ded9ad809cefd948ebc0e9412d81b0110a375",
    "fb6857b098d985da36bebdf2ec10d8ebcfd986f0e49fc1718665147179ad35f9",
    "f9448f84526e18893a031e987e8ee9d6f6e7cd84742f8ec169ecad9c86b8b6df",
    "d9d5d868f11886f7bd0b3f79302ac0d04a8590fc1dbb98d90a2f0a0a03d9022b",
    "07cb4bd0105e068fa48c8ca4e0010ca0f57407d1a19ed62812cc68d04ddd0b21"
  ],
  "id": "curltest"
}

Zebrad:

...
2024-09-05T12:24:20.920863Z  INFO zebrad::components::mempool: re-verifying mempool transactions after a chain fork transactions=0
2024-09-05T12:24:20.924840Z  INFO zebra_rpc::methods::get_block_template_rpcs: submit block accepted block_hash=block::Hash("3e12c2573d47139e946551bac9f9d00d618207c15df5b6354df081a55e2e1f38") block_height="2"
2024-09-05T12:24:20.929619Z  INFO zebra_rpc::methods::get_block_template_rpcs: submit block accepted block_hash=block::Hash("b34ec9434f4bc73e114412046348d5197e7f3b96c95d355ca538abe4f06770f8") block_height="3"
2024-09-05T12:24:20.934646Z  INFO zebra_rpc::methods::get_block_template_rpcs: submit block accepted block_hash=block::Hash("36758f0465c498874e1674fcbdb2dd0c964ef6302045ed39107c2eae60c11778") block_height="4"
2024-09-05T12:24:20.939168Z  INFO zebra_rpc::methods::get_block_template_rpcs: submit block accepted block_hash=block::Hash("c9f8332a34f8ce4abfa07161ef4b3b71fad2d8dcffcbb0fdd4b83d4c3c800981") block_height="5"
2024-09-05T12:24:20.943204Z  INFO zebra_rpc::methods::get_block_template_rpcs: submit block accepted block_hash=block::Hash("adf05c2a72d0fdd0e09be06b30a9da105566e504676d72ca6e7f91d19752bc6a") block_height="6"
2024-09-05T12:24:20.947735Z  INFO zebra_rpc::methods::get_block_template_rpcs: submit block accepted block_hash=block::Hash("eaef3b7d5bb3bfa973e3f191ecb1e3f3eadba8748f03562171b3932282e5558c") block_height="7"
2024-09-05T12:24:20.952480Z  INFO zebra_rpc::methods::get_block_template_rpcs: submit block accepted block_hash=block::Hash("699af45062d915fbbfe0b59553501eafab82a9d13442f2d16676815e261b257d") block_height="8"
2024-09-05T12:24:20.956506Z  INFO zebra_rpc::methods::get_block_template_rpcs: submit block accepted block_hash=block::Hash("21c4a0740cb2050d4a3556470cbfbc352722c62b50307a686ddc2a37517d6f12") block_height="9"
2024-09-05T12:24:20.961144Z  INFO zebra_rpc::methods::get_block_template_rpcs: submit block accepted block_hash=block::Hash("4e7ba9f9f7d0aab8c8ad2f70fe799ed04442830bb3ff20d7ab87ada7172cd511") block_height="10"
2024-09-05T12:24:20.966012Z  INFO zebra_rpc::methods::get_block_template_rpcs: submit block accepted block_hash=block::Hash("18f7940182a3ca3ac2d9a4d9fd73b895736b00e4b0593f3d855126ec0b8b3c56") block_height="11"
2024-09-05T12:24:20.971084Z  INFO zebra_rpc::methods::get_block_template_rpcs: submit block accepted block_hash=block::Hash("eac1b8e7856397f08847dba937d2778f25d398416589aadab36be82b8c357fba") block_height="12"
2024-09-05T12:24:20.975090Z  INFO zebra_rpc::methods::get_block_template_rpcs: submit block accepted block_hash=block::Hash("adc6dd3f00457b62735c7f8fbf5c9acc6bf497cc2754d30d4073fbfa07fb5248") block_height="13"
2024-09-05T12:24:20.979028Z  INFO zebra_rpc::methods::get_block_template_rpcs: submit block accepted block_hash=block::Hash("a5324ff558ad9884f4b7154e2a1d416dc6ce75de5be4af6f0d0640f808b12a70") block_height="14"
2024-09-05T12:24:20.984135Z  INFO zebra_rpc::methods::get_block_template_rpcs: submit block accepted block_hash=block::Hash("b37af61ec204c4a639ae733719c25ada478afa3e7761576c1b74b6ee33a10ba9") block_height="15"
2024-09-05T12:24:20.988670Z  INFO zebra_rpc::methods::get_block_template_rpcs: submit block accepted block_hash=block::Hash("3f0e287ef304c223a9ef35afaddd746ef2e20dc96428cfe117e53f74db197d53") block_height="16"
2024-09-05T12:24:20.993678Z  INFO zebra_rpc::methods::get_block_template_rpcs: submit block accepted block_hash=block::Hash("0511530a5e597a87a42810815491a152b5d8cdf9661a73bd55301ad439b3c539") block_height="17"
2024-09-05T12:24:20.998612Z  INFO zebra_rpc::methods::get_block_template_rpcs: submit block accepted block_hash=block::Hash("38765446837afbd0543fd365c60cd0205c82a265b61249358fbb8dc8fe3b2a1d") block_height="18"
2024-09-05T12:24:21.003760Z  INFO zebra_rpc::methods::get_block_template_rpcs: submit block accepted block_hash=block::Hash("3c60203e5f916a98afde162eea8301fb11cdcc81804584737c33f61039b49532") block_height="19"
2024-09-05T12:24:21.008084Z  INFO zebra_rpc::methods::get_block_template_rpcs: submit block accepted block_hash=block::Hash("530e88a017c53d4cabbf3125f768516004b3160c2940c419e02ececf245ec753") block_height="20"
2024-09-05T12:24:21.012077Z  INFO zebra_rpc::methods::get_block_template_rpcs: submit block accepted block_hash=block::Hash("1e9623831c16bedc78a895f8de298ef02fab2e088d0fe55d196b113e213fdeab") block_height="21"
2024-09-05T12:24:21.016969Z  INFO zebra_rpc::methods::get_block_template_rpcs: submit block accepted block_hash=block::Hash("e698024a453ef4dd2efd6fbe3caae3a8502f90c2f2b26c6134c1625457e1d328") block_height="22"
2024-09-05T12:24:21.021702Z  INFO zebra_rpc::methods::get_block_template_rpcs: submit block accepted block_hash=block::Hash("be9294e78e5fb1dac41ee22c46b3d6c278e2e8889710897981559656e824e24f") block_height="23"
2024-09-05T12:24:21.026391Z  INFO zebra_rpc::methods::get_block_template_rpcs: submit block accepted block_hash=block::Hash("c87d9a0986fb08a5bb7952c6ca92e36c399c4fd9a05ab6fc5d10367c3f9fc817") block_height="24"
2024-09-05T12:24:21.031239Z  INFO zebra_rpc::methods::get_block_template_rpcs: submit block accepted block_hash=block::Hash("36bb3fbe17a81078c4f58a74350b66742cc31dc47b656d0c2401df8184f69fa6") block_height="25"
2024-09-05T12:24:21.036373Z  INFO zebra_rpc::methods::get_block_template_rpcs: submit block accepted block_hash=block::Hash("799152b276f0b8d0a62517eda0b81e8d2ec7daad30990ae50ecad361be1af2ed") block_height="26"
2024-09-05T12:24:21.040643Z  INFO zebra_rpc::methods::get_block_template_rpcs: submit block accepted block_hash=block::Hash("c1ec7aa6cf015a806eb74c1bd746b5e53b38963bb4fb17d6eb3f6b14254bd2cd") block_height="27"
2024-09-05T12:24:21.044720Z  INFO zebra_rpc::methods::get_block_template_rpcs: submit block accepted block_hash=block::Hash("6552e88a459b926158a32fef4c22a094a5096c7f098a7afc356bee8d03176c27") block_height="28"
2024-09-05T12:24:21.049620Z  INFO zebra_rpc::methods::get_block_template_rpcs: submit block accepted block_hash=block::Hash("e3962633e53996217fe93a756d952d996198adb33aed9f8a79a058aead435376") block_height="29"
2024-09-05T12:24:21.055071Z  INFO zebra_rpc::methods::get_block_template_rpcs: submit block accepted block_hash=block::Hash("e55bdc8a6b176d1cc6a334a7d534bb8760cf35136b680cec4fa924f3efbf4c7e") block_height="30"
2024-09-05T12:24:21.059771Z  INFO zebra_rpc::methods::get_block_template_rpcs: submit block accepted block_hash=block::Hash("3aa573c3522f208cff880c9204ef597bdd3e639d1cf7976b5a185c5041936e07") block_height="31"
2024-09-05T12:24:21.064666Z  INFO zebra_rpc::methods::get_block_template_rpcs: submit block accepted block_hash=block::Hash("f831726cf1ecdc20e7c1cb85c9e9ce1da3bea65371385c863c4e41591509f4a1") block_height="32"
2024-09-05T12:24:21.069710Z  INFO zebra_rpc::methods::get_block_template_rpcs: submit block accepted block_hash=block::Hash("a9a5a84880263c951815b6d952db7e13a26798ea313ba7663e37d3317419aa00") block_height="33"
2024-09-05T12:24:21.073954Z  INFO zebra_rpc::methods::get_block_template_rpcs: submit block accepted block_hash=block::Hash("e118b808b48226e4155a8467051f02ebd6f73dd9c46b2708a65b2bb8d6c72bb3") block_height="34"
2024-09-05T12:24:21.077979Z  INFO zebra_rpc::methods::get_block_template_rpcs: submit block accepted block_hash=block::Hash("a5ed38218b4229201fb8f404e7c557b45b265f746c03e4c6e2303c9006329bc7") block_height="35"
2024-09-05T12:24:21.082732Z  INFO zebra_rpc::methods::get_block_template_rpcs: submit block accepted block_hash=block::Hash("c249ffbef431672791659066b02cdd4bb8a9afee132ba138ef4913b0cd488a7b") block_height="36"
2024-09-05T12:24:21.087806Z  INFO zebra_rpc::methods::get_block_template_rpcs: submit block accepted block_hash=block::Hash("db89db5cf8664f3d8186cd5dcb428801859fa17b782bb8c88ff1c302fdf652f8") block_height="37"
2024-09-05T12:24:21.092188Z  INFO zebra_rpc::methods::get_block_template_rpcs: submit block accepted block_hash=block::Hash("a9fdd2d2c05b0fc894d6d9612bad9bae9dffb334055a909d7043bd39f76ae3cf") block_height="38"
2024-09-05T12:24:21.096740Z  INFO zebra_rpc::methods::get_block_template_rpcs: submit block accepted block_hash=block::Hash("8db2bd8a8a104230f9729557905c01dc67b005336df6d95f322a5186456e84b0") block_height="39"
2024-09-05T12:24:21.101938Z  INFO zebra_rpc::methods::get_block_template_rpcs: submit block accepted block_hash=block::Hash("7cc306691cbe455ebc3174e7e64f558a801f039431b181efff8ba577fff77157") block_height="40"
2024-09-05T12:24:21.106245Z  INFO zebra_rpc::methods::get_block_template_rpcs: submit block accepted block_hash=block::Hash("fa280bd5f4deec102c3cd5b0fe46c825fd42b966b0f052fd3714c343c7508f94") block_height="41"
2024-09-05T12:24:21.110405Z  INFO zebra_rpc::methods::get_block_template_rpcs: submit block accepted block_hash=block::Hash("1ed6ca4da5e4c3a43fc0b4b49aad33c505946178091c86114544b0e7da0cea94") block_height="42"
2024-09-05T12:24:21.114864Z  INFO zebra_rpc::methods::get_block_template_rpcs: submit block accepted block_hash=block::Hash("e5d73b3b80fa2460b3fb26064a719a0f92a119ed1cde040848a8ae51526c0403") block_height="43"
2024-09-05T12:24:21.119941Z  INFO zebra_rpc::methods::get_block_template_rpcs: submit block accepted block_hash=block::Hash("9f9894517eb73ccfd1d61b5c596e974e3a386e7b28100b9616b5318613e2808c") block_height="44"
2024-09-05T12:24:21.124768Z  INFO zebra_rpc::methods::get_block_template_rpcs: submit block accepted block_hash=block::Hash("aa1cab5168c737e24a49a494337e97df7be8988b988db61cf24bf198b9ced6d4") block_height="45"
2024-09-05T12:24:21.129042Z  INFO zebra_rpc::methods::get_block_template_rpcs: submit block accepted block_hash=block::Hash("8cd58b6387576703906ab701223ded9ad809cefd948ebc0e9412d81b0110a375") block_height="46"
2024-09-05T12:24:21.134376Z  INFO zebra_rpc::methods::get_block_template_rpcs: submit block accepted block_hash=block::Hash("fb6857b098d985da36bebdf2ec10d8ebcfd986f0e49fc1718665147179ad35f9") block_height="47"
2024-09-05T12:24:21.138758Z  INFO zebra_rpc::methods::get_block_template_rpcs: submit block accepted block_hash=block::Hash("f9448f84526e18893a031e987e8ee9d6f6e7cd84742f8ec169ecad9c86b8b6df") block_height="48"
2024-09-05T12:24:21.142724Z  INFO zebra_rpc::methods::get_block_template_rpcs: submit block accepted block_hash=block::Hash("d9d5d868f11886f7bd0b3f79302ac0d04a8590fc1dbb98d90a2f0a0a03d9022b") block_height="49"
2024-09-05T12:24:21.146926Z  INFO zebra_rpc::methods::get_block_template_rpcs: submit block accepted block_hash=block::Hash("07cb4bd0105e068fa48c8ca4e0010ca0f57407d1a19ed62812cc68d04ddd0b21") block_height="50"
...

Follow-up Work

PR Author's Checklist

  • The PR name will make sense to users.
  • The PR provides a CHANGELOG summary.
  • The solution is tested.
  • The documentation is up to date.
  • The PR has a priority label.

PR Reviewer's Checklist

  • The PR Author's checklist is complete.
  • The PR resolves the issue.

@oxarbitrage oxarbitrage added C-testing Category: These are tests A-rpc Area: Remote Procedure Call interfaces A-compatibility Area: Compatibility with other nodes or wallets, or standard rules P-Medium ⚡ labels Sep 5, 2024
@oxarbitrage oxarbitrage requested a review from a team as a code owner September 5, 2024 12:36
@oxarbitrage oxarbitrage requested review from arya2 and removed request for a team September 5, 2024 12:36
@github-actions github-actions bot added the C-feature Category: New features label Sep 5, 2024
arya2
arya2 previously approved these changes Sep 5, 2024
Copy link
Contributor

@arya2 arya2 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good!

@oxarbitrage oxarbitrage changed the title feat(rpc): Add a generate rpc method feat(rpc): Add a generate rpc method Sep 5, 2024
mergify bot added a commit that referenced this pull request Sep 6, 2024
Copy link
Collaborator

@conradoplg conradoplg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good

@mergify mergify bot merged commit 082cdad into main Sep 9, 2024
192 checks passed
@mergify mergify bot deleted the generate-rpc branch September 9, 2024 21:51
dmidem pushed a commit to QED-it/zebra that referenced this pull request Oct 29, 2024
* implement `generate` rpc method

* update openapi

---------

Co-authored-by: Pili Guerra <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-compatibility Area: Compatibility with other nodes or wallets, or standard rules A-rpc Area: Remote Procedure Call interfaces C-feature Category: New features C-testing Category: These are tests P-Medium ⚡
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Implement generate RPC method
4 participants